package com.sunfield.windpower.http;

import android.content.Context;

import com.sunfield.baseframe.http.BaseHttpClient;
import com.sunfield.baseframe.http.HttpParams;

import org.androidannotations.annotations.EBean;

/**
 * Created by wxl on 2017/4/25.
 */
@EBean
public class HttpClient extends BaseHttpClient {

    /**
     * 门户栏目列表
     */
    public static final String URL_GET_DOOR_LIST = "app/cwp/appcolumn.jsp";
    public static final String RESULT_GET_DOOR_LIST = "{\"status\":0,\"data\":[{\"id\":\"id1\",\"name\":\"集团发文\"},{\"id\":\"id2\",\"name\":\"通知公告\"}],\"msg\":\"操作成功\"}";

    /**
     * 门户新闻列表
     */
    public static final String URL_GET_NEWS_LIST = "app/cwp/appinfolist.jsp";
    public static final String RESULT_GET_NEWS_LIST ="{\"status\":0,\"data\":{\"currentpage\":1,\"totalnum\":856,\"totalpage\":857,\"info\":[{\"id\":\"8a8a8b045063e5e601535a30032d753b\",\"num\":\"\",\"title\":\"38号--关于接收法院及仲裁等机构快递注意事项的通知--20160309\",\"image\":\"\",\"date\":\"2016-03-09\"},{\"id\":\"8a8a8b045063e5e601535a30032d753b\",\"num\":\"\",\"title\":\"38号--关于接收法院及仲裁等机构快递注意事项的通知--20160309\",\"image\":\"\",\"date\":\"2016-03-09\"}]},\"msg\":\"操作成功\"}";
//    public static final String RESULT_GET_NEWS_LIST ="{\"status\":0,\"data\":{\"currentpage\":1,\"totalnum\":856,\"totalpage\":857,\"info\":[{\"id\":\"8a8a8b045063e5e601535a30032d753b\",\"num\":\"\",\"title\":\"38号--关于接收法院及仲裁等机构快递注意事项的通知--20160309\",\"image\":\"\",\"date\":\"2016-03-09\"}]},\"msg\":\"操作成功\"}";
    public static final String RESULT_GET_NEWS_LIST_EMPTY ="{\"status\":0,\"data\":{\"currentpage\":1,\"totalnum\":856,\"totalpage\":857,\"info\":[]},\"msg\":\"操作成功\"}";

    /**
     * 门户新闻详情
     */
    public static final String URL_GET_NEWS_DETAIL = "app/cwp/appdocbaseview.jsp";
    public static final String RESULT_GET_NEWS_DETAIL ="{\"status\":0,\"data\":{\"content\":\"\n" +
            " <\\/p>\\r\\n\n" +
            "各附属公司：<\\/o:p><\\/span><\\/span><\\/p>\\r\\n\n" +
            "法院、仲裁等机构发出的快递与普通快递不同，接收单位如果处理不当将对公司造成极为严重的后果。接收单位拒绝签收法院快递可能会导致法院公告送达，使公司无法知道正在进行的诉讼程序，承担非常不利的后果；签收快递后在规定期限内不及时做出处理，使法院或仲裁机构视为公司放弃了法定的权利，将严重影响到公司的利益。为避免出席上述情况，维护公司利益，现就法院、仲裁等机构相关快递接收注意事项通知如下：<\\/o:p><\\/span><\\/span><\\/p>\\r\\n\n" +
            "一、集团各子公司、控股公司、经注册登记的分公司(<\\/span>简称“附属公司”)<\\/span>在签收法院、仲裁委等机构寄送的相关快递后，务必在签收当日拆开快递，将快递内文件、快递签收单扫描后通过电子邮件发送至集团法律合规部，电子邮件发出后须立即电话联系法律合规部再次确认。快递原件及快递签收单原件请务必妥善保管，等待法律合规部下一步安排。<\\/o:p><\\/span><\\/span><\\/p>\\r\\n\n" +
            "二、如果各附属公司如注册地址与实际办公地址不一致，请确保法院或仲裁机构寄送到注册地址的快递有专门人员及时签收，并且签收后能够按本通知第一条规定及时进行处理。<\\/o:p><\\/span><\\/span><\\/p>\\r\\n\n" +
            "三、各附属公司在接到相关快递公司尤其是EMS<\\/span>公司的快递送达通知时，务必了解清楚是否由法院、仲裁等机构寄出，如果是法院、仲裁等机构发出的快递，在无人签收的情况下，不得让其采取直接放在前台、物业或塞入门缝等方式处理。<\\/o:p><\\/span><\\/span><\\/p>\\r\\n\n" +
            "四、各附属公司负责收发快递的人员，需每日仔细检查快递公司送来的直接堆放在前台的快递，是否有法院、仲裁等机构发出的快递，发现后立即按本通知第一条规定及时处理。<\\/o:p><\\/span><\\/span><\\/p>\\r\\n\n" +
            "五、没有集团法律合规部的批准，不得随意拒绝签收法院、仲裁等机构寄送的相关快递。<\\/span><\\/o:p><\\/span><\\/p>\\r\\n\n" +
            "请各附属公司负责人及相关人员知悉以上事项，并做好落实工作，<\\/span>如发生违反上述规定导致公司利益受损的情况，集团将追究相关人员及单位负责<\\/span>人的责任。<\\/o:p><\\/span><\\/span><\\/p>\\r\\n\n" +
            "特此通知。<\\/o:p><\\/span><\\/span><\\/p>\\r\\n\n" +
            " <\\/o:p><\\/span><\\/p>\\r\\n\n" +
            "协合新能源集团有限公司<\\/o:p><\\/span><\\/span><\\/p>\\r\\n\n" +
            "2016年3月9日<\\/span><\\/p>\\r\\n\n" +
            " <\\/o:p><\\/span><\\/p>\",\"id\":\"8a8a8b045063e5e601535a30032d753b\",\"files\":[{\"name\":\"38--协合新能源法字〔2016〕38号--关于接收法院及仲裁等机构快递注意事项的通知--20160309.PDF\",\"type\":\"application\\/pdf\",\"url\":\"http:\\/\\/oa.cnegroup.com\\/ServiceAction\\/com.eweaver.document.file.FileDownload?docid=8a8a8b045063e5e601535a30032d753b&attachid=8a8a8b045063e5e601535a2fc9e37538 target='_blank' title='打开'>38--协合新能源法字〔2016〕38号--关于接收法院及仲裁等机构快递注意事项的通知--20160309.PDF<\\/a>122.99KB<\\/span>\"}],\"author\":\"刘莹\",\"title\":\"38号--关于接收法院及仲裁等机构快递注意事项的通知--20160309\",\"column\":\"jtfw\",\"dept\":\"行政部\",\"date\":\"2016-03-09\"},\"msg\":\"操作成功\"}\n";

    /**
     * 未读消息数量
     */
    public static final String URL_GET_UNREAD_MESSAGE_COUNT = "app/cwp/appunreadmsg.jsp";
    public static final String RESULT_GET_UNREAD_MESSAGE_COUNT = "{\"status\":0,\"data\":10,\"msg\":\"操作成功\"}";

    /**
     * 阅读消息
     */
    public static final String URL_READ_MESSAGE = "app/cwp/appreadmsg.jsp";
    public static final String RESULT_READ_MESSAGE = "{\"status\":0,\"msg\":\"操作成功\"}";

    /**
     * 消息列表
     */
    public static final String URL_GET_MESSAGE_LIST = "app/cwp/appmsglist.jsp";
    public static final String RESULT_GET_MESSAGE_LIST = "{\"status\":0,\"data\":{\"currentpage\":1,\"totalnum\":2,\"totalpage\":1,\"info\":[{\"id\":\"id1\",\"title\":\"集团发文\",\"date\":\"2017-05-21\",\"url\":\"http:\\/\\/\"},{\"id\":\"id2\",\"title\":\"通知公告\",\"date\":\"2017-05-24\",\"url\":\"http:\\/\\/\"}]},\"msg\":\"操作成功\"}";

    /**
     * 获取用户信息
     */
    public static final String URL_GET_USERINFO = "app/cwp/appuserinfo.jsp";
    public static final String RESULT_GET_USERINFO = "{\"status\":0,\"data\":{\"companyid\":\"id2\",\"userid\":\"id1\"},\"msg\":\"操作成功\"}";

    /**
     * 导航菜单
     */
    public static final String URL_GET_GUIDE_MENU = "app/cwp/appnav.jsp";
    public static final String RESULT_GET_GUIDE_MENU = "{\"status\":0,\"data\":[{\"id\":\"id1\",\"icon\":1,\"name\":\"集团发文\",\"type\":2,\"url\":\"http:\\/\\/\"},{\"id\":\"id2\",\"icon\":1,\"name\":\"通知公告\",\"type\":2,\"url\":\"http:\\/\\/\"}],\"msg\":\"操作成功\"}";

    public HttpClient(Context context) {
        super(context);
    }

    /**
     * 导航列表
     */
    public void getMenuList() {
        HttpParams httpParams = createHttpParams(URL_GET_GUIDE_MENU, "getMenuList").setShowDialog(false).setCancelDialog(false).setResult(RESULT_GET_GUIDE_MENU);
        httpParams.post();
    }

    /**
     * 门户栏目列表
     */
    public void getDoorList() {
        HttpParams httpParams = createHttpParams(URL_GET_DOOR_LIST, "getDoorList").setCancelDialog(true).setResult(RESULT_GET_DOOR_LIST);
        httpParams.post();
    }

    /**
     * 门户新闻列表
     *
     * @param beginPage 起始页数，从0开始
     * @param pageSize  每页条数
     * @param companyId 公司id
     * @param columnId  栏目id
     */
    public void getNewsList(String companyId, String columnId, int beginPage, int pageSize, int configKey) {
        HttpParams httpParams = createHttpParams(URL_GET_NEWS_LIST, "getNewsList")
                .setShowDialog(false)
                .setConfigKey(configKey)
                .setResult(beginPage > 3 ? RESULT_GET_NEWS_LIST_EMPTY : RESULT_GET_NEWS_LIST);
        httpParams.addParam("beginPage", String.valueOf(beginPage));
        httpParams.addParam("pageSize", String.valueOf(pageSize));
        httpParams.addParam("companyId", companyId);
        httpParams.addParam("columnId", columnId);
        httpParams.post();
    }

    /**
     * 门户新闻详情
     *
     * @param articleId 新闻id
     */
    public void getNewsDetail(String articleId) {
        HttpParams httpParams = createHttpParams(URL_GET_NEWS_DETAIL, "getNewsDetail").setResult(RESULT_GET_NEWS_DETAIL);
        httpParams.addParam("id", articleId);
        httpParams.post();
    }

    /**
     * 当前用户未读消息数量
     *
     * @param userId 用户id
     */
    public void getUnreadMessageCount(String userId) {
        HttpParams httpParams = createHttpParams(URL_GET_UNREAD_MESSAGE_COUNT, "getUnreadMessageCount")
                .setResult(RESULT_GET_UNREAD_MESSAGE_COUNT)
                .setToastMsg(false)
                .setShowDialog(false)
                .setCancelDialog(false)
                .setNeedLock(false);
        httpParams.addParam("userId", userId);
        httpParams.post();
    }

    /**
     * 将当前用户的未读消息置为已读状态
     *
     * @param userId 用户id
     */
    public void readMessage(String userId) {
        HttpParams httpParams = createHttpParams(URL_READ_MESSAGE, "readMessage")
                .setResult(RESULT_READ_MESSAGE)
                .setToastMsg(false)
                .setShowDialog(false)
                .setCancelDialog(false)
                .setNeedLock(false);
        httpParams.addParam("userId", userId);
        httpParams.post();
    }

    /**
     * 当前用户的消息列表
     *
     * @param userId    用户id
     * @param beginPage 起始页数，从0开始
     * @param pageSize  每页条数
     */
    public void getMessageList(String userId, String beginPage, String pageSize) {
        HttpParams httpParams = createHttpParams(URL_GET_MESSAGE_LIST, "getMessageList").setResult(RESULT_GET_MESSAGE_LIST);
        httpParams.addParam("userId", userId);
        httpParams.addParam("beginPage", beginPage);
        httpParams.addParam("pageSize", pageSize);
        httpParams.post();
    }

    /**
     * 获取用户信息
     *
     * @param ticket 登录ticket
     */
    public void getUserInfo(String ticket) {
        HttpParams httpParams = createHttpParams(URL_GET_USERINFO, "getUserInfo").setResult(RESULT_GET_USERINFO).setShowDialog(false);
        httpParams.addParam("ticket", ticket);
        httpParams.post();
    }


}
